<!DOCTYPE html>
<!--[if IE 8]>
<html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]>
<html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
    <meta charset="utf-8"/>
    <title>会员管理 - 会员列表</title>
    <?php include($this->c['_homes']['_viewsHome'] . '/_global/_head.php'); ?>
</head>
<!-- BEGIN BODY -->
<body class="page-header-fixed page-sidebar-fixed">
<!-- BEGIN HEADER -->
<?php include($this->c['_homes']['_viewsHome'] . '/_global/head.php'); ?>
<!-- END HEADER -->
<div class="clearfix"></div>
<!-- BEGIN CONTAINER -->
<div class="page-container">
    <!-- BEGIN HORIZONTAL MENU PAGE SIDEBAR1 -->
    <?php include($this->c['_homes']['_viewsHome'] . '/_global/menu.php'); ?>
    <!-- END BEGIN HORIZONTAL MENU PAGE SIDEBAR -->
    <!-- BEGIN PAGE -->
    <div class="page-content">
        <!-- BEGIN SAMPLE PORTLET CONFIGURATION MODAL FORM-->
        <div class="modal fade" id="portlet-config" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
             aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                        <h4 class="modal-title">Modal title</h4>
                    </div>
                    <div class="modal-body">
                        Widget settings form goes here
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn blue submit_btn">确定</button>
                        <button type="button" class="btn default" data-dismiss="modal">取消</button>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal-dialog -->
        </div>
        <!-- /.modal -->
        <!-- END SAMPLE PORTLET CONFIGURATION MODAL FORM-->
        <!-- BEGIN PAGE HEADER-->
        <div class="row">
            <div class="col-md-12">
                <!-- BEGIN PAGE TITLE & BREADCRUMB-->
                <h3 class="page-title"> 会员列表 </h3>
                <ul class="page-breadcrumb breadcrumb">
                    <li><i class="icon-home"></i> <a href="/manage">后台</a> <i class="icon-angle-right"></i></li>
                    <li> 会员管理 <i class="icon-angle-right"></i></li>
                    <li>会员列表</li>
                </ul>
                <!-- END PAGE TITLE & BREADCRUMB-->
            </div>
        </div>
        <!-- END PAGE HEADER-->
        <!-- BEGIN PAGE CONTENT-->
        <div class="row">
            <div class="col-md-12">
                <div class="portlet box">
                    <div class="booking-search">
                        <form action="" role="form" method="get" id="forms">
                            <div class="row form-group">
                                <div class="col-md-2">
                                    <div class="input-cont">
                                        <input class="form-control" name="keyword" placeholder="邀请码/手机号码/姓名/会员昵称" value="<?= $_GET['keyword']; ?>" type="text">
                                    </div>
                                </div>
                                <div class="col-md-2">
                                   <select class="form-control" name="member_level">
                                    <option value="">会员级别</option>
                                    <?php
                                       foreach ($this->c['member'] as $k => $r)
                                       {

                                           if (isset($this->data['para']['member_level']) && $this->data['para']['member'] == $k) $slk = ' selected';
                                           else $slk = '';

                                           echo '<option value="' . $k . '"' . $slk . '>' . $r . '</option>';
                                       }
                                       ?>
                                    </select>
                                </div>
                                <div class="col-md-2">
                                   <select class="form-control" name="agent_level">
                                    <option value="">荣誉级别</option>
                                    <?php
                                       foreach ($this->c['honor'] as $k => $r)
                                       {

                                           if (isset($this->data['para']['agent_level']) && $this->data['para']['agent_level'] == $k) $slk = ' selected';
                                           else $slk = '';

                                           echo '<option value="' . $k . '"' . $slk . '>' . $r . '</option>';
                                       }
                                       ?>
                                    </select>
                                </div>
                                <div class="col-md-2">
                                    <select class="form-control" name="maker_level">
                                        <option value="">创客级别</option>
                                        <?php
                                        foreach ($this->c['maker'] as $k => $r)
                                        {

                                            if (isset($this->data['para']['maker_level']) && $this->data['para']['maker_level'] == $k) $slk = ' selected';
                                            else $slk = '';

                                            echo '<option value="' . $k . '"' . $slk . '>' . $r . '</option>';
                                        }
                                        ?>
                                    </select>
                                </div>
                                <div class="col-md-2">
                                    <select class="form-control" id="stat" name="stat">
                                        <option value="">登录状态</option>
                                        <option value="1"<? if ($this->data['para']['statue'] == 1) echo ' selected'; ?>>
                                            正常
                                        </option>
                                        <option value="2"<? if ($this->data['para']['statue'] == 2) echo ' selected'; ?>>
                                            禁用
                                        </option>
                                    </select>
                                </div>
                            </div>
                                <div class="row form-group">
                                                            
                                <div class="col-md-1"><input type="submit" class="btn blue btn-block" value="搜索"></div>
<!--                                    <div class="col-md-2"><input type="button" class="btn green btn-block" value='导出Excel' onclick="_export();"></div>-->
                                    <div class="col-md-2"><input type="button" class="btn green btn-block" value='导出CSV' onclick="_exportCsv();"></div>
                            </div>

                        </form>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                <!-- BEGIN SAMPLE TABLE PORTLET-->
                <div class="portlet box blue">
                    <div class="portlet-title">
                        <div class="caption"><i class="icon-list"></i>列表(<?= $this->data['count']; ?>)</div>
                        <div class="tools"><a href="javascript:;" class="collapse"></a></div>
                    </div>
                    <div class="portlet-body">
                        <div class="table-scrollable">
                            <table class="table table-striped table-bordered table-hover dataTable">
                                <thead>
                                <tr>
                                    <th>UID</th>
                                    <th>邀请码</th>
                                    <th>手机号码</th>
                                    <th>会员头像</th>
                                    <th>会员昵称</th>
                                    <th>姓名</th>
                                    <th>推荐人</th>
                                    <th>推荐人邀请码</th>
                                    <th>TA的推荐</th>
                                    <th>注册时间</th>
                                    <th>绑定手机时间</th>
                                    <th>会员级别</th>
                                    <th>荣誉级别</th>
                                    <th>创客级别</th>
                                    <th>硒豆</th>
                                    <th>可提现</th>
                                    <th>金花</th>
                                    <th>硒米</th>
                                    <th>代金券</th>
                                    <th>商品票</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php
                                if ($this->data['data']) {
                                    foreach ($this->data['data'] as $k => $r) {
                                ?>
                                <tr>
                                    <td><?=$r['uid']; ?></td>                                  
                                    <td><?=$r['recode']; ?></td>
                                    <td><?=$r['mobile']; ?></td>
                                    <td><?php
                                    $headimgurl = '/style/assets/img/avatar.png';
                                    if($r['headimgurl']> 0 && $this->data['docs'][$r['headimgurl']])
                                    {
                                        $headimgurl = $this->data['docs'][$r['headimgurl']];
                                    }
                                    elseif($r['wechat_headimgurl']!="")
                                    {
                                        $headimgurl = $r['wechat_headimgurl'];
                                    }
                                    ?><img src="<?=$headimgurl;?>" width="45" height="45" />                                            
                                    </td>
                                    <td><?=$r['realname']; ?></td>
                                    <td><?=$r['name']; ?></td>
                                    <td><?=$r['pid']> 0 && $this->data['parents'][$r['pid']] ? '['.$r['pid'].'] <a href="?pid='.$r['pid'].'">'.$this->data['parents'][$r['pid']]['realname'].'</a>' : '--';?></td>
                                    <td><?=$r['pid']> 0 && $this->data['parents'][$r['pid']] ? $this->data['parents'][$r['pid']]['recode'] : '--';?></td>
                                    <td><a href="?pid=<?=$r['uid'];?>"><?=$this->data['child'][$r['uid']] >0 ?$this->data['child'][$r['uid']]: 0;?>人</a></td>
                                    <td><?=date("Y-m-d H:i", $r['create_time']);?></td>
                                    <td><?= $r['bind_time']>0 ?date("Y-m-d H:i", $r['bind_time']):"";?></td>
                                    <td><?=$this->c['member_level'][$r['member_level']];?></td>
                                    <td><?=$this->c['honor_level'][$r['agent_level']];?></td>
                                    <td><?=$this->c['maker_level'][$r['maker_level']];?></td>
                                    <td><?=$this->data['balance'][$r['uid']]['money'];?></td>
                                    <td><?=$this->data['balance'][$r['uid']]['revenue'];?></td>
                                    <td><?=$this->data['balance'][$r['uid']]['gold_money'];?></td>
                                    <td><?=$this->data['balance'][$r['uid']]['ximi_money'];?></td>
                                    <td><?=$this->data['balance'][$r['uid']]['coupon'];?></td>
                                    <td><?=$this->data['balance'][$r['uid']]['ticket'];?></td>
                                    <td><?=$this->c['stat']['normal'][$r['stat']];?></td>
                                    <td>
                                        <?php
                                        if($this->pv['edit'])
                                        {
                                            echo '<a href="edit?uid='.$r['uid'].'" class="btn btn-xs blue"><i class="icon-edit"></i> 编辑</a> ';
                                        }

                                        if($this->pv['recharge'])
                                        {
                                            echo '<a href="recharge?uid='.$r['uid'].'" class="btn btn-xs blue"><i class="icon-signin"></i> 充值</a> ';
                                        }
                                        ?>
                                    </td>
                                </tr>
                                <?
                                    }
                                }
                                ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <?php
                if ($this->data['maxpage'] > 1) {
                    ?>
                    <div>
                        <ul class="pagination">
                            <?
                            $pquery = "?";
                            if ($this->data['para']) {
                                foreach ($this->data['para'] as $k => $r) {
                                    $pquery .= $k . "=" . $r . "&";

                                    $form_hidden .= '<input type="hidden" name="' . $k . '" value="' . $r . '">';
                                }
                            }

                            if ($this->data['page'] > 1) echo '<li><a href="' . $pquery . 'page=' . ($this->data['page'] - 1) . '"><i class="icon-angle-left"></i></a></li>';
                            for ($i = $this->data['spage']['ps']; $i <= $this->data['spage']['pe']; $i++) {
                                if ($i == $this->data['page']) echo '<li class="disabled"><a href="javascript:void(0);">' . $i . '</a></li>';
                                else echo '<li><a href="' . $pquery . 'page=' . $i . '">' . $i . '</a></li>';
                            }

                            if ($this->data['page'] < $this->data['maxpage']) echo '<li><a href="' . $pquery . 'page=' . ($this->data['page'] + 1) . '"><i class="icon-angle-right"></i></a></li>';
                            ?>
                        </ul>

                        <div class="jumppage">
                            <form method="get" action="">
                                <?= $form_hidden; ?>
                                页码：<?= $this->data['page']; ?>/<?= $this->data['maxpage']; ?>
                                跳到 <input type="text" name="page" class="value"> 页
                                <input type="submit" value="GO" class="sub">
                            </form>
                        </div>
                    </div>
                    <?
                }
                ?>
                <!-- END SAMPLE TABLE PORTLET-->
            </div>
        </div>
        <!-- END PAGE CONTENT-->
    </div>
    <!-- END PAGE -->
</div>
<!-- END CONTAINER -->
<!-- END CONTAINER -->
<form method="post" id="_frm" action="/member/savemember">
    <input type="hidden" name="act" value="delete">
    <input type="hidden" name="uid" id="_uid" value="0">
</form>
<?php include($this->c['_homes']['_viewsHome'] . '/_global/_footer.php'); ?>
<script>
    var _submit_action = '', _uid = 0;
    jQuery(document).ready(function () {
        App.init();
        $(".submit_btn").bind("click", function () {
            switch (_submit_action) {
                case "delete":
                    _delete_action();
                    break;
            }
        });
    });

    function _delete_alert(uid) {
        _submit_action = 'delete';
        _uid = uid;
        $("#portlet-config .modal-title").html('删除会员');
        $("#portlet-config .modal-body").html('<p>确定删除此会员吗？</p> <p class="alert alert-danger">警告：删除后不可恢复</p>');
    }

    function _delete_action() {
        $("#_uid").prop("value", _uid);
        $("#_frm").submit();
    }

    function _export()
    {
        var obj = $('#forms').serialize();
        window.open("export?"+obj);

    }
    function _exportCsv() {
        var obj = $('#forms').serialize();
        window.open("export_csv?"+obj);
    }
</script>
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>